#include "dwt.h"

double RunningTime;

void DWT_start(void){
	DEM_CR |= (u32)DEM_CR_TRCENA;				// 使能DWT
	DWT_CYCCNT = (u32)0;						// 寄存器清零
	DWT_CR |= (u32)DWT_CR_CYCCNTENA;			// 使能寄存器，开始计时
}

void DWT_end(void){
	RunningTime = (double) DWT_CYCCNT;
	DWT_CR |= (u32)0;			// 去能寄存器，关闭计时	
	RunningTime = RunningTime / SystemCoreClockFrequency;
}

